import request from '@/utils/request'

/**
 * 查询菜单列表
 */
export function getMenuList(query?: any) {
  return request.get('/system/menu/list', query)
}

/**
 * 查询菜单详细
 */
export function getMenu(menuId: number) {
  return request.get(`/system/menu/${menuId}`)
}

/**
 * 查询菜单下拉树结构
 */
export function getMenuTreeSelect() {
  return request.get('/system/menu/treeselect')
}

/**
 * 根据角色ID查询菜单下拉树结构
 */
export function roleMenuTreeSelect(roleId: number) {
  return request.get(`/system/menu/roleMenuTreeselect/${roleId}`)
}

/**
 * 新增菜单
 */
export function addMenu(data: any) {
  return request.post('/system/menu', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '菜单新增成功',
  })
}

/**
 * 修改菜单
 */
export function updateMenu(data: any) {
  return request.put('/system/menu', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '菜单修改成功',
  })
}

/**
 * 删除菜单
 */
export function delMenu(menuId: number) {
  return request.delete(`/system/menu/${menuId}`, {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '菜单删除成功',
  })
}
